import 'package:flutter/material.dart';

/// 水印组件
class Watermark extends StatelessWidget {
  Widget child;
  final String text;

  Watermark({super.key, required this.child, this.text = ""});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Stack(
      children: [
        child,
        _createWatermark(),
      ],
    );
  }

  /// 创建水印
  Widget _createWatermark() {
    return IgnorePointer(
      child: Column(
        children: List.generate(
          6,
          (index) => Expanded(
            child: Row(
              children: List.generate(
                3,
                (index) => Expanded(
                  child: Center(
                    child: Transform.rotate(
                      angle: -0.34,
                      child: Text(
                        text,
                        style: const TextStyle(
                          color: Color(0x10000000),
                          fontSize: 14,
                          decoration: TextDecoration.none,
                        ),
                      ),
                    ),
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
